<?php

//链接 swoole tcp 服务
$client = new swoole_client(SWOOLE_SOCK_TCP);


if (!$client->connect('127.0.0.1', 9501, -1))
{
    exit("连接失败: {$client->errCode}\n");
}

//php cli 常量
fwrite(STDOUT,"请输入消息:");
$msg = trim(fgets(STDIN));

//把msg 发送给tcp server服务器
$client->send($msg);

// 接受来自server的数据
$result = $client->recv();

echo $result;

